package com.ItTallents.Maria.Nikola.Ivan.cardsgame;

import gameLogic.Login;
import gameLogic.User;
import gameLogic.UserSqlHelper;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

public class UserActivity extends Activity {

	private Login login;

	private TextView username;
	private TextView score;
	private TextView easy;
	private TextView medium;
	private TextView hard;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
        setContentView(R.layout.activity_user);

        login = Login.getInstance(new User("pesho"), new UserSqlHelper(this));
		username = (TextView) findViewById(R.id.username);

		score = (TextView) findViewById(R.id.score);
		easy = (TextView) findViewById(R.id.easyLevel);
		medium = (TextView) findViewById(R.id.mediumLevel);
		hard = (TextView) findViewById(R.id.hardLevel);

		initFields();
	}

	public void initFields() {
		username.setText(login.getLoggedUser().getName());
		score.setText("score " + login.getLoggedUser().getCurrentScore());
		easy.setText("easy " + login.getLoggedUser().getCurrentEasyLevel());
		medium.setText("medium " + login.getLoggedUser().getCurrentMediumLevel());
		hard.setText("hard " + login.getLoggedUser().getCurrentHardLevel());
	}

	public void increm(View v) {
		login.getLoggedUser().setCurrentEasyLevel(
				login.getLoggedUser().getCurrentEasyLevel() + 1);
		login.updateUserInfo();
	}

	@Override
	protected void onDestroy() {
		login.logOut();
		super.onDestroy();
	}
}
